package com.tbsoft.core.action;

import org.apache.camel.Exchange;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import com.tbsoft.core.process.AbstractProcess;
/**
 * @desc actionBeanContext作为一个endpoint接入Camel路由处理Camel路由过来的数据 
 * @author tudongyun
 *
 */
public class ActionBeanContext extends AbstractProcess
implements ApplicationContextAware{
	ApplicationContext context;
	@Override
	public void setApplicationContext(ApplicationContext arg0)
			throws BeansException {
		this.context=arg0;
	}
	
	
	@Override
	public void execute(Exchange exchange) throws Exception {
		//getBean参数目前hardcode,可考虑从消息中取对应的action或者根据消息类型来映射对应的action
		ActionBeanInterface action = (ActionBeanInterface) context.getBean("purchaseActionBean");
		action.perform(exchange);
	}
	


}
